/*
 * Copyright (c) 2002 Boris Pruessmann and others. All rights reserved. This
 * program and the accompanying materials are made available under the terms of
 * the Common Public License v0.5 which accompanies this distribution, and is
 * available at http://www.eclipse.org/legal/cpl-v05.html
 * 
 * Contributors: Boris Pruessmann - Initial implementation.
 */
package net.sourceforge.perforce.ui.internal;

import java.io.InputStream;

import net.sourceforge.perforce.core.resources.RemoteFile;

import org.eclipse.core.resources.IStorage;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.team.core.TeamException;

/**
 * @version $Revision: 488 $
 * @author <a href="mailto:bpruessmann@users.sourceforge.net">Boris Pr??mann</a>
 */
public class RemoteFileStorage extends PlatformObject implements IStorage {
  private RemoteFile file;

  public RemoteFileStorage(RemoteFile file) {
    this.file = file;
  }

  /** @see IStorage#getContents() */
  public InputStream getContents() throws CoreException {
    try {
      return file.getContents(new NullProgressMonitor());
    } catch (TeamException e) {
      throw new CoreException(e.getStatus());
    }
  }

  /** @see IStorage#getFullPath() */
  public IPath getFullPath() {
    return new Path(file.getName());
  }

  /** @see IStorage#getName() */
  public String getName() {
    return file.getName();
  }

  /** @see IStorage#isReadOnly() */
  public boolean isReadOnly() {
    return true;
  }

}
